package com.zjhn.ds.controller.pc;

import com.alibaba.fastjson.JSON;
import com.zjhn.ds.common.BizResult;
import com.zjhn.ds.common.PageResult;
import com.zjhn.ds.domain.dto.pc.EquipmentDto;
import com.zjhn.ds.domain.dto.pc.StationDto;
import com.zjhn.ds.param.AddUpdateEquipmentParam;
import com.zjhn.ds.param.AddUpdateStationParam;
import com.zjhn.ds.param.EquipmentPageParam;
import com.zjhn.ds.param.StationPageParam;
import com.zjhn.ds.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @BelongsProject: ds_jlw
 * @BelongsPackage: com.zjhn.ds.controller.pc
 * @Author: sxt
 * @CreateTime: 2023-09-13  14:30
 * @Description:
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/jlw/device")
@Api(tags = "pc端设备与工位接口")
public class DeviceController {

    @Resource
    private DeviceService deviceService;

    @ApiOperation("新增/更新设备机台信息")
    @PostMapping("/addUpdateEquipment")
    public BizResult<?> addUpdateEquipment(@RequestBody @Valid AddUpdateEquipmentParam param) {
        log.info("====[INFO]========DeviceController====addUpdateEquipment param:{}", JSON.toJSONString(param));
        return deviceService.addUpdateEquipment(param);
    }

    @ApiOperation("删除设备机台")
    @GetMapping("/removeEquipment")
    public BizResult<?> removeEquipment(@RequestParam("equipment_id") String equipmentId) {
        log.info("====[INFO]========DeviceController====removeEquipment equipmentId:{}", equipmentId);
        return deviceService.removeEquipment(equipmentId);
    }

    @ApiOperation("按条件分页查询设备机台信息")
    @PostMapping("/equipmentPage")
    public BizResult<PageResult<EquipmentDto>> equipmentPage(@RequestBody @Valid EquipmentPageParam param) {
        log.info("====[INFO]========DeviceController====equipmentPage param:{}", JSON.toJSONString(param));
        return deviceService.equipmentPage(param);
    }

    @ApiOperation("新增/更新工位信息")
    @PostMapping("/addUpdateStation")
    public BizResult<?> addUpdateStation(@RequestBody @Valid AddUpdateStationParam param) {
        log.info("====[INFO]========DeviceController====addUpdateStation param:{}", JSON.toJSONString(param));
        return deviceService.addUpdateStation(param);
    }

    @ApiOperation("删除工位信息")
    @GetMapping("/removeStation")
    public BizResult<?> removeStation(@RequestParam("station_id") String stationId) {
        log.info("====[INFO]========DeviceController====removeStation stationId:{}", stationId);
        return deviceService.removeStation(stationId);
    }

    @ApiOperation("按条件分页查询工位信息")
    @PostMapping("/stationPage")
    public BizResult<PageResult<StationDto>> stationPage(@RequestBody @Valid StationPageParam param) {
        log.info("====[INFO]========DeviceController====stationPage param:{}", JSON.toJSONString(param));
        return deviceService.stationPage(param);
    }

}
